package com.googlecode.ddlutilstool.kernel;

import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

/**
 * <p>Class Main</p>
 * 
 * <p>This is simply the main() function, starting the application.</p>
 * 
 * <p>It sets up the logging, then creates the ProfileManager, ExecuteManager
 * and GuiManager.</p>
 */
public class Main {

	private final static String LOGGING_CONFIG_FILE = "/META-INF/log4j.properties";

	public static void main(String[] args) throws Exception {
		Logger log;
		InputStream i = Main.class.getResourceAsStream(LOGGING_CONFIG_FILE);
		Properties loggingProperties = new Properties();
		loggingProperties.load(i);
		PropertyConfigurator.configure(loggingProperties);
		log = Logger.getLogger(Main.class.getName());
		log.info("Logging Enabled.");

		try {
			ProfileManager profile = ProfileManager.getInstance();
			profile.init();
			ExecuteManager execute = ExecuteManager.getInstance();
			execute.init();
			GuiManager gui = GuiManager.getInstance();
			gui.init();
		}
		catch (Exception e) {
			if (log.isDebugEnabled()) log.debug(e);
			log.error(e.getMessage());
		}
	}

}
